package com.baizhi.cmfzmanager.controller;

import com.baizhi.cmfzmanager.entity.Lesson;
import com.baizhi.cmfzmanager.service.LessonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class LessonController {
    @Autowired
    private LessonService lessonService;
    @RequestMapping("/getLessons.do")
    public Map getLessons(Integer page,Integer rows){
        return lessonService.getLessons(page,rows);
    }
    @RequestMapping("/addLesson.do")
    public Map addLesson(Lesson lesson){
        Map map=new HashMap();
        try {
            lessonService.addLesson(lesson);
            map.put("isAdd",true);
        } catch (Exception e) {
            map.put("isAdd",false);
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return map;
    }
    @RequestMapping("deleteLesson.do")
    public Map deleteLesson(int[] id){
        Map map=new HashMap();
        try {
            lessonService.deleteLesson(id);
            map.put("isUpdate",true);
        } catch (Exception e) {
            map.put("isUpdate",false);
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return map;
    }
}
